<%@page import="shmged.com.shlcm.workflow.setparticipant.TpViewTaskBean"%>
<%@page import="wt.org.WTUser"%>
<%@page import="java.util.Iterator"%>
<%@page import="wt.team.Team"%>
<%@page import="wt.project.Role"%>
<%@page import="wt.team.TeamHelper"%>
<%@page import="wt.org.WTPrincipalReference"%>
<%@page import="java.util.HashMap"%>
<%@page import="wt.workflow.definer.UserEventVector"%>
<%@page import="com.ptc.netmarkets.workflow.NmWorkflowHelper"%>
<%@page import="wt.fc.QueryResult"%>
<%@page import="wt.workflow.engine.WfVotingEventAudit"%>
<%@page import="wt.workflow.work.WorkflowHelper"%>
<%@page import="wt.fc.WTStringSet"%>
<%@page import="java.util.List"%>
<%@page import="wt.workflow.engine.WfProcess"%>
<%@page import="wt.fc.Persistable"%>
<%@page import="wt.httpgw.URLFactory"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="wt.workflow.engine.WfActivity"%>
<%@page import="wt.workflow.work.WorkItem"%>
<%@page import="wt.fc.ReferenceFactory"%>
<%@page import="wt.workflow.engine.ProcessData"%>
<%@page import="wt.maturity.PromotionNotice"%>
<%@page import="wt.part.WTPart"%>
<%@page import="wt.workflow.engine.WfVariable"%>
<%@page import="wt.doc.WTDocument"%>
<%@page import="shmged.com.shlcm.workflow.setparticipant.TpWorkflowHelper"%>
<%
	String baseUrl = new URLFactory().getBaseHREF();
    TpViewTaskBean taskBean = TpViewTaskBean.newTpCompleteTaskBean(request);
%>
<html>
<head>
<title>流程审批</title>
<link rel="stylesheet" type="text/css" href="<%=baseUrl%>shmged/javascript/util/jquery-easyui-1.3.3/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="<%=baseUrl%>shmged/javascript/util/jquery-easyui-1.3.3/themes/icon.css">
<script type="text/javascript">var pageBaseUrl = "<%=baseUrl%>";</script>
<script type="text/javascript" src="<%=baseUrl%>shmged/javascript/util/jquery-easyui-1.3.3/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="<%=baseUrl%>shmged/javascript/util/jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=baseUrl%>shmged/jsp/com/shlcm/portal/js/main.js"></script>
<style type="text/css">
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
</style>
</head>
<body>
	<div style="margin: 10px 0;"></div>
	<div class="easyui-panel" title="<%=taskBean.getActiveName()%>"
		style="width: 890px">
		<div style="margin: 10px 0;"></div>
		<form method="post" enctype="multipart/form-data" name="commitWork"
			id="commitWork">
			<table>
				<tr>
					<td width="80px" align="right">流程名称:</td>
					<td><%=taskBean.getActiveName()%></td>
				</tr>
				<tr>
					<td align="right">主题:</td>
					<td><a href="javaScript:void(0)"
						onclick="subWorkItem('<%=taskBean.getWorkitemOid()%>')"><%=taskBean.getTpSubject()%></a></td>
				</tr>
				<tr>
					<td align="right">状态:</td>
					<td><%=taskBean.getTpState()%></td>
				</tr>
				<%
					ProcessData tpwaData =  taskBean.getActivityData();
				    ProcessData tpflowData = taskBean.getWorkflowData();
					if(null != tpwaData && null != tpflowData){
						WfVariable dvar = tpwaData.getVariable("TpDisplayVar");
						String displayStr = null;
						if(null != dvar){
							displayStr = (String)dvar.getValue();
						}
						String [] varNames;
						if(null == displayStr || displayStr.trim().length() == 0){
							varNames = new String[0];
						}else{
							varNames = displayStr.trim().split(";");
						}
					  for(int tpi = 0 ;tpi < varNames.length;tpi++){
						  WfVariable flowVar = tpflowData.getVariable(varNames[tpi]);
						  if(null == flowVar){
							  continue;
						  }
				%>
				<tr>
					<td align="right"><%=flowVar.getDisplayName()%>:</td>
					<td><%=null == flowVar.getValue() ? "": flowVar.getValue()%></td>
				</tr>
				<%
					  }
					}
				HashMap<Role,List<WTPrincipalReference> > rolePrincipalListMap = taskBean.getRolePrincipalListMap();
				if(null != rolePrincipalListMap){
					Iterator<Role> roles = rolePrincipalListMap.keySet().iterator();
					Role role = null;
					List<WTPrincipalReference> refs = null;
					while(roles.hasNext()){
						role = roles.next();
						refs = rolePrincipalListMap.get(role);
						if(null == refs || refs.isEmpty()){
							continue;
						}
						String tpUsers = "";
						WTUser user = null;
						for(int i = 0 ;i < refs.size();i++){
							user = (WTUser)refs.get(i).getObject();
							if(tpUsers.length() > 0){
								tpUsers = tpUsers +";&nbsp;"+user.getFullName();
							}else{
								tpUsers = user.getFullName();
							}
						}
				%>
						<tr>
						<td align="right"><%=role.getFullDisplay()%>:</td>
					    <td><%=tpUsers %></td>
					    </tr>
				<%
					}
				}
					WfVotingEventAudit tpAudit = taskBean.getVoteAudit();
					UserEventVector tpUserEvent = null;
					UserEventVector eventsV = taskBean.getUserEvent();
					if(null != tpAudit){
						tpUserEvent = tpAudit.getEventList();
					}else{
						tpUserEvent = new UserEventVector();
					}
					for(int i=0;i<eventsV.size();i++){
						String mychecked ="";
						if(null != tpUserEvent && tpUserEvent.contains(eventsV.get(i))){
							mychecked ="checked='checked'";
						}
				%>
				<tr>
					<td align="right"><%=eventsV.get(i)%></td>
					<td><input type="radio" name="userEvent" readonly="readonly" disabled="disabled" value="<%=eventsV.get(i)%>" <%=mychecked %>></input></td>
				</tr>
				<%}%>

			</table>
		</form>
	</div>
</body>
</html>


